﻿using MySSO.Core.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;

namespace MySSO.Core.Repository
{
    public class IPCityRepository : BaseRepository
    {
        public IPCityEntity GetIPCityByIpValue(long ipValue)
        {
            IPCityEntity iPCityEntity = null;
            string sql = @"SELECT [IP_ID],[StartIP],[EndIP],[IP_Province],[IP_City],[IP_County] FROM cms_IPCity WITH(NOLOCK) where StartIP<= @ipValue AND EndIP>=@ipValue";
            using (var connection = GetConnection())
            {
                iPCityEntity = connection.QueryFirstOrDefault<IPCityEntity>(sql, new { ipValue = ipValue });
            }

            return iPCityEntity;

        }
    }
}
